package com.cq.hd.app.controller;

import com.cq.hd.app.biz.IndexBiz;
import com.cq.hd.app.dto.IndexPositionDto;
import com.cq.hd.app.vo.IndexPositionVo;
import com.cq.hd.app.vo.MyPageVo;
import com.cq.hd.common.annotation.LoginUser;
import com.cq.hd.common.entity.AppLoginUser;
import com.cq.hd.common.response.Result;
import com.cq.hd.common.response.ResultGenerator;
import com.cq.hd.system.api.vo.HfRegionVo;
import com.cq.hd.system.api.vo.RegionVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;


@RestController
@RequestMapping("/index")
@Api(tags = "首页相关接口")
public class IndexController {

    @Autowired
    private IndexBiz indexBiz;

    @ApiOperation(value = "根据经纬度返回地区数据")
    @ApiResponse(response = IndexPositionVo.class, code = 200, message = "接口返回对象参数")
    @PostMapping("/position")
    public Result<IndexPositionVo> position(@RequestBody IndexPositionDto indexPositionDto) {
        return ResultGenerator.success(indexBiz.position(indexPositionDto));
    }

    @ApiOperation(value = "获取已有商家入驻的省市列表所有数据")
    @ApiImplicitParam(name = "cityName", value = "市区名称", paramType = "query", dataType = "String")
    @ApiResponse(response = HfRegionVo.class, code = 200, message = "接口返回对象参数")
    @GetMapping("/listRegion")
    public Result<List<HfRegionVo>> listRegion(String cityName) {
        return ResultGenerator.success(indexBiz.listRegion(cityName));
    }

    @ApiOperation(value = "我的页面数据")
    @ApiResponse(response = MyPageVo.class, code = 200, message = "接口返回对象参数")
    @GetMapping("/myPage")
    public Result<MyPageVo> myPage(@ApiIgnore @LoginUser AppLoginUser appLoginUser) {
        return ResultGenerator.success(indexBiz.myPage(appLoginUser));
    }

}
